###############################################################
#Replication File for: An Unexpected Short: How Livestream Selling Shapes Firm Value
###############################################################

###Prepared by Qiyuan Wang, June 09, 2024, Email: qiyuan.wang@polyu.edu.hk

##############File List###################
#File Name						 #Explanation#
---------------------------------------------------------------------------
# README.txt 					#main file for describing replication process
---------------------------------------------------------------------------
# InfluencerList.csv				#the list of influencers used for analysis
# BrandnameStockIndex.csv		#the link between brand name in livestream data and stock index in the financial data
# Weibo.csv					#the full weibo data
# FirmProfileCode.csv			#the manually coded data for firm profile
---------------------------------------------------------------------------
#Main.r						#R code for the main analysis

##############Data Access###################
###Influencer Data
	##Data provider: https://www.huitun.com/
	##Influencer list: please see InfluencerList.csv for the complete influencer list
	##Data tables
		#livestream-product table: observation at each product level for each livestream selling session, fields cover influencer ID, livestreaming date, product name, brand name, price, sales volume etc.
		#Influencer profile table: observation at each influencer level, fields cover influencer ID, follower size, industry focus etc.

###Stock Data
	##Data provider: https://global.csmar.com/
	##Data tables
		#Stock daily price table: observation at each stock-day level, fields cover stock ID, date, stock price etc.
		#Firm financial variables tables: observation at each stock-quarter or stock-year level,  fields cover stock ID, date, sales, leverage, management size etc
		#Announcement tables: observation at each announcement level, fields cover announcement ID, firm ID, date, announcement title, announcement category etc.

###Brand Name to Stock Index Data
	##Data provider: we directly use the search engine to identify which stock index the brand name is associated with
	##Please see the data at BrandnameStockIndex.csv

###News Data
	##Data provider: https://www.ringdata.com/
	##Data tables
		##News data: observation at each news level, fields cover news url, source, title, date, content etc.

###Weibo Data
	##Data provider: we directly scrape the data from weibo.com
	##please see the data file at Weibo.csv

###Premium Position, Product/service, and Industry Category Data
	##Data provider: we ask research assistant to mannually code such data
	##Please see the data at FirmProfileCode.csv

##############Data Processing###################
###We describe the general data processing steps before main analysis
###Step 1: calculating the abnormal return
	##calculating the daily stock return
	##using the corresponding baseline asset pricing model to calculate the expected stock return
	##daily stock return - expected stock return= abnormal return
###Step 2: merge stock index to livestream data
	##merge stock index to livestream product level
	##aggregate the livestream product at stock index-day level, which constitutes our events
###Step 3: merge abnormal return to livestream data
	##determine the event window based on stock index and day from livestream data
	##sum the abnormal return in this event window to obtain the cumulative abnormal return
###Step 4: merge moderating variables and control variables
	##use the stock index and date to merge all moderating varaibles and control variables, including the inverse mills ratio
###Step 5: main analysis
	##use the finalized data to conduct the main analysis and moderating analysis

##############Data Analysis###################
###Please see Main.r for the code of conducting analysis in R
###we briefly describe the analysis process here

###Main Effect
	##calculate the cumulative abnormal return by using different window specification
	##use t.test in R to conduct t test
	##report both the effect size, t statistics, and p value

###Main Effect: Robustness Checks
	##check 1: drop observations when there are announcements in the event window
	##check 2: drop observations with event window overlapped with window of other observations
	##check 3: split observations with single vs. multiple product appearances and test effect seperately

###Moderating Analysis
	##conduct the regression analysis by using felm function from the lfe package in R based on the event window [t,t+3]
	##report estimates, standard errors, and p value

###Moderating Analysis: Robustness Checks
	##check 1: compute cumulative abnormal return using alternative baseline asset pricing model and conduct the regression analysis
	##check 2: compute cumulative abnormal return using alternative event window and conduct the regression analysis

#end

